<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:asp="remove">
  <xsl:output method="xml" indent="yes" encoding="utf-8" omit-xml-declaration="yes"/>
  <!--<xsl:param name="employeeId"/>-->
  <xsl:param name="employeeId"/>
  <xsl:template name="HomeAddress" match="/root/info">
    <h2>
      <xsl:value-of select="@Caption"/>
    </h2>
    <table cellspacing="10" cellpadding="0">
      <xsl:for-each select="child::*">
        <xsl:variable name="rowindex" select="position()"></xsl:variable>
        <xsl:variable name="varType" select="@Type"></xsl:variable>
        <xsl:variable name="isRequired" select="@Required"></xsl:variable>
        <xsl:variable name="varId" select="translate(concat(concat(concat(@Caption,'_'),$rowindex),position()),' ','_')"></xsl:variable>
        <xsl:variable name="up" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
        <xsl:variable name="lo" select="'abcdefghijklmnopqrstuvwxyz'"/>
        <tr>
          <td>
            <b>
              <xsl:value-of select="@Caption"/>
            </b>
          </td>
          <td>
            <xsl:choose>
              <xsl:when test="translate($varType,$up,$lo)='textarea'">
                <asp:TextBox ID="{$varId}" runat="server" Height="227px" Text="{.}" Width="478px"></asp:TextBox>
              </xsl:when>
              <xsl:when test="translate($varType,$up,$lo)='imgfile'">
                <asp:FileUpload ID="{$varId}" runat="server" />
                <asp:HiddenField ID="{concat('hidden',$rowindex)}" runat="server" value="{.}"/>
                <img src=".{.}" style="max-width:80px;max-height:80px;padding-left:10px;vertical-align: middle;" />
              </xsl:when>
              <xsl:otherwise>
                <asp:TextBox ID="{$varId}" runat="server" Text="{.}" width="205px" ></asp:TextBox>
                <xsl:if test="translate($isRequired,$up,$lo)='yes'">
                  <asp:RequiredFieldValidator ErrorMessage=" Required Field" runat="server" ControlToValidate="{$varId}" />
                </xsl:if>
              </xsl:otherwise>
            </xsl:choose>
          </td>
        </tr>
      </xsl:for-each>
      <tr>
        <td></td>
        <td>
          <asp:Button ID="btnSaveAddress" runat="server" Font-Names="Tahoma" Font-Size="10pt" Text="Lưu Lại" />
        </td>
      </tr>
    </table>
  </xsl:template>
</xsl:stylesheet>